package com.nyist.zk.controller;


import com.nyist.zk.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpSession;

@Controller
public class loginController {

    @Autowired
    private AdminService adminService;

    @GetMapping("/admin")
    public String toAdminLogin() {
        System.out.println("管理员登录");
        return "admin/adminLogin";
    }

    @GetMapping("/doctor")
    public String toDoctorLogin() {
        System.out.println("医生登录");
        return "doctor/doctorLogin";
    }

    @GetMapping("/blood")
    public String toBloodManagerLogin() {
        System.out.println("血库管理员登录");
        return "bloodManager/bloodManagerLogin";
    }

    @GetMapping("/patient")
    public String toPatientLogin() {
        System.out.println("病人登录");
        return "patient/patientLogin";
    }

    @GetMapping("/logout")
    public String logout(HttpSession session) {
        //1. 清空session中的用户信息
        session.removeAttribute("loginUser");
        //2. 再将session进行注销
        session.invalidate();
        //3. 返回登录页面
        return "redirect:/patient";
    }






}
